package com.ruoyi.module.studyCenterDetail.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.module.studyCenterDetail.domain.StudyCenterDetail;
import com.ruoyi.module.studyCenterDetail.service.IStudyCenterDetailService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 学习中心详情Controller
 * 
 * @author yqq
 * @date 2024-04-19
 */
@RestController
@RequestMapping("/api/studyCenterDetail")
public class StudyCenterDetailController extends BaseController
{
    @Autowired
    private IStudyCenterDetailService studyCenterDetailService;

    /**
     * 查询学习中心详情列表
     */
    @PreAuthorize("@ss.hasPermi('api:studyCenterDetail:list')")
    @GetMapping("/list")
    public TableDataInfo list(StudyCenterDetail studyCenterDetail)
    {
        startPage();
        List<StudyCenterDetail> list = studyCenterDetailService.selectStudyCenterDetailList(studyCenterDetail);
        return getDataTable(list);
    }

    /**
     * 导出学习中心详情列表
     */
    @PreAuthorize("@ss.hasPermi('api:studyCenterDetail:export')")
    @Log(title = "学习中心详情", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, StudyCenterDetail studyCenterDetail)
    {
        List<StudyCenterDetail> list = studyCenterDetailService.selectStudyCenterDetailList(studyCenterDetail);
        ExcelUtil<StudyCenterDetail> util = new ExcelUtil<StudyCenterDetail>(StudyCenterDetail.class);
        util.exportExcel(response, list, "学习中心详情数据");
    }

    /**
     * 获取学习中心详情详细信息
     */
    @PreAuthorize("@ss.hasPermi('api:studyCenterDetail:query')")
    @GetMapping(value = "/{detailId}")
    public AjaxResult getInfo(@PathVariable("detailId") Long detailId)
    {
        return success(studyCenterDetailService.selectStudyCenterDetailByDetailId(detailId));
    }

    /**
     * 新增学习中心详情
     */
    @PreAuthorize("@ss.hasPermi('api:studyCenterDetail:add')")
    @Log(title = "学习中心详情", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody StudyCenterDetail studyCenterDetail)
    {
        return toAjax(studyCenterDetailService.insertStudyCenterDetail(studyCenterDetail));
    }

    /**
     * 修改学习中心详情
     */
    @PreAuthorize("@ss.hasPermi('api:studyCenterDetail:edit')")
    @Log(title = "学习中心详情", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody StudyCenterDetail studyCenterDetail)
    {
        return toAjax(studyCenterDetailService.updateStudyCenterDetail(studyCenterDetail));
    }

    /**
     * 删除学习中心详情
     */
    @PreAuthorize("@ss.hasPermi('api:studyCenterDetail:remove')")
    @Log(title = "学习中心详情", businessType = BusinessType.DELETE)
	@DeleteMapping("/{detailIds}")
    public AjaxResult remove(@PathVariable Long[] detailIds)
    {
        return toAjax(studyCenterDetailService.deleteStudyCenterDetailByDetailIds(detailIds));
    }
}
